package com.blog.controller;

import com.blog.common.CommonRespDto;
import com.blog.common.RespBean;
import com.blog.seckill.accounts.HrAccount;
import com.blog.service.HrAccountBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

/**
 * @ClassName HrAccountBaseController
 * @Destription HrAccount基础：增删改查
 * @Author 天堂小野花
 * @Date 2025/8/19  19:16
 * @Version 1.0
 */
@RestController
@RequestMapping("/hrAccount")
public class HrAccountBaseController {
    @Autowired
    HrAccountBaseService hrAccountBaseService;
    @PutMapping("/hrAccountAdjustByHrId")
    public int hrAccountAdjustByHrId(@RequestParam("price") BigDecimal price,@RequestParam("hrid") Integer hrid){

        if(hrAccountBaseService.hrAccountAdjustByHrId(price,hrid) == 1){
            return 1;
        }
        return 0;
    }
    @GetMapping("/selectAllHrAccount")
    public CommonRespDto selectAllHrAccount(){
        return CommonRespDto.success(hrAccountBaseService.selectAllHrAccount());
    }
    @GetMapping("/base/selectHrAccountById/{rid}")
    public CommonRespDto selectHrAccountById(@PathVariable Integer rid){
        return CommonRespDto.success(hrAccountBaseService.selectHrAccountById(rid));
    }

    @PostMapping("/base/insertHrAccount")
    public RespBean insertHrAccount(@RequestBody HrAccount hrAccount){
        if(hrAccountBaseService.insertHrAccount(hrAccount) == 1 ){
            return RespBean.ok("添加成功");
        }
        return RespBean.error("添加失败");
    }
    @DeleteMapping("/base/deleteHrAccount/{rid}")
    public RespBean deleteHrAccountById(@PathVariable Integer rid){
        if(hrAccountBaseService.deleteHrAccountById(rid) == 1){
            return RespBean.ok("删除成功");
        }
        return RespBean.error("删除失败");
    }
    @PutMapping("/base/updateHrAccount")
    public RespBean updateHrAccount(@RequestBody HrAccount hrAccount){

        if(hrAccountBaseService.updateHrAccount(hrAccount) == 1){
            return RespBean.ok("更新成功");
        }
        return RespBean.error("更新失败");
    }
}
